from urllib import request
# from ua_info import ua_list
from fake_useragent import UserAgent
import random


ua = UserAgent()
# 随机选择一个User-Agent
headers = {
    "User-Agent": ua.random,
}

# 爬取百度首页
url = "https://www.baidu.com"

# 发送请求
req = request.Request(url, headers=headers)
# 打开请求
response = request.urlopen(req)

# 读取响应内容
html = response.read().decode("utf-8")
print(html)
